package com.key.controller.admin.analysisReport;

import com.github.pagehelper.PageHelper;
import com.key.common.R;
import com.key.common.dto.AssetsFindDTO;
import com.key.common.dto.EndAssetsFindDTO;
import com.key.common.vo.AssetListVO;
import com.key.common.vo.AssetListVO1;
import com.key.common.vo.AssetsVO;
import com.key.mapper.AssetListMapper;
import com.key.service.AssetListService;
import com.key.service.AssetsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author：朕
 * @Package：com.key.controller.admin.analysisReport
 * @Project：ams_system
 * @name：AssetList
 * @Date：2023/2/18 9:08
 * @Filename：AssetList
 */
@Controller
@Api(value = "分析报表",tags = "资产清单的API")
@RequestMapping("/AssetList")
public class AssetListController {

    @Autowired
    private AssetListService assetListService;



    @RequestMapping(value = "/findAssetsList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "显示资产清单",notes = "",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true),
   })
    public R findAssetsList(Integer currentPage, Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        List<AssetListVO1> assetListVO1s = assetListService.findAssetsList();
        if(assetListVO1s.size()>0){
            r.setCode(200);
            r.setMsg("显示成功");
            r.setData(assetListVO1s);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("显示失败");
            return r;
        }
    }


    @RequestMapping(value = "/findAssetsListByCompany",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "根据公司名称查询资产清单",notes = "公司名称",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyName",value = "公司名称",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true),
    })
    public R findAssetsListByCompany(String companyName , Integer currentPage, Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        List<AssetListVO1> ass = assetListService.findAssetListByCompanyName(companyName);
        if(ass.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(ass);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }

    @RequestMapping(value = "/findAssetsListByDepartment",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "根据部门名称查询资产清单",notes = "部门名称",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "departmentName",value = "部门名称",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true),
    })
    public R findAssetsListByDepartment( String departmentName, Integer currentPage, Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        List<AssetListVO1> assetListVO1s = assetListService.findAssetListByDepartment(departmentName);
        if(assetListVO1s.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(assetListVO1s);
            System.out.println("200");
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            System.out.println("500");
            return r;
        }
    }

    @ApiOperation(value = "根据高级搜索查询资产接口",notes = "根据高级搜索查询所有资产列表",httpMethod = "get", response = R.class)
    @RequestMapping(value = "/findAssetsListByAnd",method = RequestMethod.GET)
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "aml",value = "查询数据",paramType = "query",dataType = "String",required = true),
    })
    public R findAssetsListByAnd(String aml){
        R r = new R();
        List<AssetListVO1> assetListVO1s = assetListService.findAssetListByAnd(aml);
        if(assetListVO1s.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(assetListVO1s);
            System.out.println("200");
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            System.out.println("500");
            return r;
        }
    }

}

